package com.jiazhong.mingxing.boot.boot14.listener;

import com.alibaba.fastjson.JSONArray;
import com.jiazhong.mingxing.boot.boot14.bean.Order;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

@RocketMQMessageListener(consumerGroup = "abc2", topic = "TopicB",
        selectorExpression = "transaction1", messageModel = MessageModel.BROADCASTING)
@Slf4j
@Component
public class AddressListener implements RocketMQListener<String> {

    @Override
    public void onMessage(String s) {
        log.info("onMessage:{}", s);
        Order order = JSONArray.parseObject(s, Order.class);
        log.info("开始向{}发货", order.getAddress());
    }
}
